﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Security.Claims;

namespace CookieDemo.Web.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            return View();
        }

        [Authorize(Roles = "Admin")]
        public IActionResult Auth()
        {
            var names = HttpContext.User.FindAll(c => c.Type == ClaimTypes.Name);
            ViewBag.CurrentUserName = names != null && names.Any() ? names.First().Value : "tester";
            return View();
        }
    }
}